#include<bits/stdc++.h>
#define eps (1e-3)
using namespace std;
int n, m, L, V;
bool allpositive = true;

int read()
{
    int f = 1, x = 0; char ch; ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return f * x;
}

struct Block
{
    int L, R;
}a[100005];
int spos[100005], vp0[100005], ap0[100005];
int til;
int Warning[100005];

bool cmp(Block &A, Block &B)
{
    return A.R < B.R;
}

void check()
{
    if(a[til].L > a[til].R)
        a[til].L = a[til].R = 0, til--;
}

int BinarySearch(int pos)
{
    int L = 1, R = m, ans = 1, mid;
    while(L <= R)
    {
        mid = (L + R) >> 1;
        if(Warning[mid] >= pos)
            ans = mid, R = mid - 1;
        else
            L = mid + 1;
    }
    return ans;
}

int BinarySearch2(int pos)
{
    int L = 1, R = m, ans = 1, mid;
    while(L <= R)
    {
        mid = (L + R) >> 1;
        if(Warning[mid] <= pos)
            ans = mid, L = mid + 1;
        else
            R = mid - 1;
    }
    return ans;
}

void calLR(int cur)
{
    int st = spos[cur], v0 = vp0[cur], a0 = ap0[cur];
    if(st > Warning[m])
        return;
    if(a0 == 0 && v0 > V)
    {
        a[++til].L = BinarySearch(st), a[til].R = m;
    }
    if(a0 < 0)
    {
        if(v0 <= V)
            return;
        a[++til].L = BinarySearch(st);
        a[til].R = BinarySearch2(st + ceil((double)(v0 - V) * (double)(v0 + V) / (double)(-a0) / 2.0) - 1);
        check();
    }
    if(a0 > 0)
    {
        if(v0 > V)
        {
            a[++til].L = BinarySearch(st), a[til].R = m;
            check();
            return;
        }
        int Reach = st + floor((double)(V - v0) * (double)(V + v0) / (double)(a0) / 2.0) + 1;
        if(Reach > Warning[m])
            return;
        a[++til].L = BinarySearch(Reach), a[til].R = m;
        check();
    }
}


int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T = read();
    while(T--)
    {
        memset(spos, 0, sizeof spos);
        memset(vp0, 0, sizeof vp0);
        memset(ap0, 0, sizeof ap0);
        memset(a, 0, sizeof a);
        memset(Warning, 0, sizeof Warning);
        til = 0;
        n = read(), m = read(), L = read(), V = read();
        for(int i = 1; i <= n; i++)
        {
            spos[i] = read(), vp0[i] = read(), ap0[i] = read();
            if(ap0[i] <= 0)
                allpositive = false;
        }
        for(int i = 1; i <= m; i++)
            Warning[i] = read();
        for(int i = 1; i <= n; i++)
            calLR(i);
        cout << til << " ";
        if(allpositive)
        {
            cout << m - 1 << "\n";
            continue;
        }
        sort(a + 1, a + til + 1, cmp);
        int lastw = 0, ans = 0;
        for(int i = 1; i <= til; i++)
        {
            if(a[i].L <= lastw)
                continue;
            else
                ans++, lastw = a[i].R;
        }
        cout << m - ans << "\n";
    }
    return 0;
}
